package com.gitee.wsl.struct.attribute.pairs


typealias Case = LinkedHashMap<String, Any?>

fun Case(vararg input: Any):LinkedHashMap<String, Any?>{
    val list = LinkedHashMap<String, Any?>()
    var i = 0
    while (i < input.size) {
        list.put(input[i] as String, input[i + 1])
        i += 2
    }
    return list
}

fun Case(base: List<Item?>):LinkedHashMap<String, Any?>{
    val list = LinkedHashMap<String, Any?>()
    base.forEach { item: Item? ->
        item?.let {
            check(!list.containsKey(item.name)) { "Duplicate key: " + item.name }
            list.put(item.name, item.value)
        }
    }
    return list
}


/**
 * A [LinkedHashMap] representing single test case.
 *
 *  * `key` is the [Parameter] name
 *  * `value` is one of the [Parameter] values selected by AllPairs algorithm
 *
 */
/*
class Case : LinkedHashMap<String, Any?> {
    constructor() : super()
    constructor(map: Map<String, *>) : super(map)

    constructor(base: List<Item?>): super() {
        base.forEach { item: Item? ->
            item?.let {
                check(!super.containsKey(item.name)) { "Duplicate key: " + item.name }
                super.put(item.name, item.value)
            }
        }
    }

    */
/**
     * Creates [Case].
     *
     * @param input varargs. Must be an odd number of arguments. Each odd argument is a key of [String] type.
     * Each even argument is a value of [Object] type.
     *//*

    constructor(vararg input: Any) {
        //require( input.size.isOdd ) { "Input length is odd. Unable to create map" }
        var i = 0
        while (i < input.size) {
            super.put(input[i] as String, input[i + 1])
            i += 2
        }
    }


}*/
